/*
 * Copyright (C) 2010 MoSync AB
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef MAINTERPETER_TINYJSINTERPRETER_H
#define MAINTERPETER_TINYJSINTERPRETER_H

#include <tinyjs/TinyJS.h>
#include <tinyjs/TinyJS_Functions.h>
#include "AbstractInterpreter.h"

namespace MAInterpreter
{

/**
 * Interface to the TinyJS interpreter.
 * http://www.pur3.co.uk/view.php?TinyJS
 * http://code.google.com/p/tiny-js/
 */
class TinyJSInterpreter : public AbstractInterpreter
{
public:
	TinyJSInterpreter();
	virtual ~TinyJSInterpreter();
	int initialize();
	void close();
	int runScript(const char* script);
	void onInit();
	void onDraw();
	void onClockTick();
	void onTouchDown(int x, int y);
	void onTouchUp(int x, int y);
	void onTouchDrag(int x, int y);
	void onKeyDown(int keyCode);
	void onKeyUp(int keyCode);

	void callFunctionWithNumericArguments(
		const char* funName,
		int numberOfArguments,
		int arg1,
		int arg2);

public:
	CTinyJS interpreter;
};

}

#endif
